﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Outpatient.Migrations
{
    /// <inheritdoc />
    public partial class add_table_OtpAppyFormDetl : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "WkstLoginRec",
                schema: "Outpatient");

            migrationBuilder.RenameColumn(
                name: "DeptInfoName",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptName");

            migrationBuilder.RenameColumn(
                name: "DeptInfoId",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptId");

            migrationBuilder.RenameColumn(
                name: "DeptInfoCodg",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptCodg");

            migrationBuilder.CreateTable(
                name: "OtpAppyFormDetl",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpAppyFormId = table.Column<Guid>(type: "uuid", nullable: false),
                    IndexNo = table.Column<string>(type: "text", nullable: false),
                    PubItemId = table.Column<Guid>(type: "uuid", nullable: false),
                    PubItemCodg = table.Column<string>(type: "text", nullable: false),
                    PubItemName = table.Column<string>(type: "text", nullable: false),
                    SpcmTypeCodg = table.Column<string>(type: "text", nullable: true),
                    SpcmTypeName = table.Column<string>(type: "text", nullable: true),
                    ExamPart = table.Column<string>(type: "text", nullable: true),
                    Cnt = table.Column<int>(type: "integer", nullable: false),
                    Pric = table.Column<decimal>(type: "numeric", nullable: false),
                    OrdTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    OperRmCodg = table.Column<string>(type: "text", nullable: true),
                    OperRmName = table.Column<string>(type: "text", nullable: true),
                    ChkDrCodg = table.Column<string>(type: "text", nullable: true),
                    ChkDrName = table.Column<string>(type: "text", nullable: true),
                    ChkTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    ExecTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    ExecDrCodg = table.Column<string>(type: "text", nullable: true),
                    ExecDrName = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpAppyFormDetl", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpAppyFormDetl_OtpAppyForm_OtpAppyFormId",
                        column: x => x.OtpAppyFormId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpAppyForm",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "OtpWkstLoginRec",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptId = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptCodg = table.Column<string>(type: "text", nullable: false),
                    DeptName = table.Column<string>(type: "text", nullable: false),
                    OperRmCodg = table.Column<string>(type: "text", nullable: false),
                    OperRmName = table.Column<string>(type: "text", nullable: false),
                    LoginDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    LoginTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    LogoutTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    LoginDrId = table.Column<Guid>(type: "uuid", nullable: false),
                    LoginDrCodg = table.Column<string>(type: "text", nullable: false),
                    LoginDrName = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpWkstLoginRec", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OtpAppyFormDetl_OtpAppyFormId",
                schema: "Outpatient",
                table: "OtpAppyFormDetl",
                column: "OtpAppyFormId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OtpAppyFormDetl",
                schema: "Outpatient");

            migrationBuilder.DropTable(
                name: "OtpWkstLoginRec",
                schema: "Outpatient");

            migrationBuilder.RenameColumn(
                name: "DeptName",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptInfoName");

            migrationBuilder.RenameColumn(
                name: "DeptId",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptInfoId");

            migrationBuilder.RenameColumn(
                name: "DeptCodg",
                schema: "Outpatient",
                table: "OtpOperRm",
                newName: "DeptInfoCodg");

            migrationBuilder.CreateTable(
                name: "WkstLoginRec",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptCodg = table.Column<string>(type: "text", nullable: false),
                    DeptId = table.Column<Guid>(type: "uuid", nullable: false),
                    DeptName = table.Column<string>(type: "text", nullable: false),
                    DrId = table.Column<Guid>(type: "uuid", nullable: false),
                    LoginDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    LoginTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    LogoutTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    OtpConsultRmCodg = table.Column<string>(type: "text", nullable: false),
                    OtpConsultRmId = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpConsultRmName = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_WkstLoginRec", x => x.Id);
                });
        }
    }
}
